<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>move_base中自定义导航算法插件制作 | 荒岛</title><meta name="author" content="Fi9zero"><meta name="copyright" content="Fi9zero"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="move_base中自定义导航算法插件制作流程：1.创建工作空间2.创建导航包文件3.创建头文件和源文件4.写CMakeLists.txt生成库文件5.建立插件描述文件xml6.配置package.xml7.查询插件是否注册8.在move_base中调用插件   继承基类：需继承 nav_core::BaseGlobalPlanner 并重写虚函数。    虚函数 作用    initialize">
<meta property="og:type" content="article">
<meta property="og:title" content="move_base中自定义导航算法插件制作">
<meta property="og:url" content="https://ckyfi9zero.github.io/2025/05/20/2025-05-20-move_base%E4%B8%AD%E8%87%AA%E5%AE%9A%E4%B9%89%E5%AF%BC%E8%88%AA%E7%AE%97%E6%B3%95%E6%8F%92%E4%BB%B6%E5%88%B6%E4%BD%9C/index.html">
<meta property="og:site_name" content="荒岛">
<meta property="og:description" content="move_base中自定义导航算法插件制作流程：1.创建工作空间2.创建导航包文件3.创建头文件和源文件4.写CMakeLists.txt生成库文件5.建立插件描述文件xml6.配置package.xml7.查询插件是否注册8.在move_base中调用插件   继承基类：需继承 nav_core::BaseGlobalPlanner 并重写虚函数。    虚函数 作用    initialize">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://ckyfi9zero.github.io/image/avatar.jpg">
<meta property="article:published_time" content="2025-05-20T06:34:23.000Z">
<meta property="article:modified_time" content="2025-07-28T08:43:10.000Z">
<meta property="article:author" content="Fi9zero">
<meta property="article:tag" content="ROS">
<meta property="article:tag" content="move_base">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://ckyfi9zero.github.io/image/avatar.jpg"><script type="application/ld+json">{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "move_base中自定义导航算法插件制作",
  "url": "https://ckyfi9zero.github.io/2025/05/20/2025-05-20-move_base%E4%B8%AD%E8%87%AA%E5%AE%9A%E4%B9%89%E5%AF%BC%E8%88%AA%E7%AE%97%E6%B3%95%E6%8F%92%E4%BB%B6%E5%88%B6%E4%BD%9C/",
  "image": "https://ckyfi9zero.github.io/image/avatar.jpg",
  "datePublished": "2025-05-20T06:34:23.000Z",
  "dateModified": "2025-07-28T08:43:10.000Z",
  "author": [
    {
      "@type": "Person",
      "name": "Fi9zero",
      "url": "https://ckyfi9zero.github.io"
    }
  ]
}</script><link rel="shortcut icon" href="/image/favicon.ico"><link rel="canonical" href="https://ckyfi9zero.github.io/2025/05/20/2025-05-20-move_base%E4%B8%AD%E8%87%AA%E5%AE%9A%E4%B9%89%E5%AF%BC%E8%88%AA%E7%AE%97%E6%B3%95%E6%8F%92%E4%BB%B6%E5%88%B6%E4%BD%9C/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><script>
    (() => {
      
    const saveToLocal = {
      set: (key, value, ttl) => {
        if (!ttl) return
        const expiry = Date.now() + ttl * 86400000
        localStorage.setItem(key, JSON.stringify({ value, expiry }))
      },
      get: key => {
        const itemStr = localStorage.getItem(key)
        if (!itemStr) return undefined
        const { value, expiry } = JSON.parse(itemStr)
        if (Date.now() > expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return value
      }
    }

    window.btf = {
      saveToLocal,
      getScript: (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        Object.entries(attr).forEach(([key, val]) => script.setAttribute(key, val))
        script.onload = script.onreadystatechange = () => {
          if (!script.readyState || /loaded|complete/.test(script.readyState)) resolve()
        }
        script.onerror = reject
        document.head.appendChild(script)
      }),
      getCSS: (url, id) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onload = link.onreadystatechange = () => {
          if (!link.readyState || /loaded|complete/.test(link.readyState)) resolve()
        }
        link.onerror = reject
        document.head.appendChild(link)
      }),
      addGlobalFn: (key, fn, name = false, parent = window) => {
        if (!false && key.startsWith('pjax')) return
        const globalFn = parent.globalFn || {}
        globalFn[key] = globalFn[key] || {}
        globalFn[key][name || Object.keys(globalFn[key]).length] = fn
        parent.globalFn = globalFn
      }
    }
  
      
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode

      const theme = saveToLocal.get('theme')
    
          theme === 'dark' ? activateDarkMode() : theme === 'light' ? activateLightMode() : null
        
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        document.documentElement.classList.toggle('hide-aside', asideStatus === 'hide')
      }
    
      
    const detectApple = () => {
      if (/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)) {
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
  
    })()
  </script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"未找到符合您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false,"highlightFullpage":false,"highlightMacStyle":true},
  copy: {
    success: '复制成功',
    error: '复制失败',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'null',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyloadPlugin: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'move_base中自定义导航算法插件制作',
  isHighlightShrink: false,
  isToc: true,
  pageType: 'post'
}</script><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="/css/pig.css"><link rel="stylesheet" href="https://npm.elemecdn.com/ethan4116-blog/lib/css/plane_v2.css"><meta name="generator" content="Hexo 7.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img text-center"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data text-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(/image/per%20page.jpg);"><nav id="nav"><span id="blog-info"><a class="nav-site-title" href="/"><span class="site-name">荒岛</span></a><a class="nav-page-title" href="/"><span class="site-name">move_base中自定义导航算法插件制作</span><span class="site-name"><i class="fa-solid fa-circle-arrow-left"></i><span>  返回首页</span></span></a></span><div id="menus"><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></span></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">move_base中自定义导航算法插件制作</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2025-05-20T06:34:23.000Z" title="发表于 2025-05-20 14:34:23">2025-05-20</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2025-07-28T08:43:10.000Z" title="更新于 2025-07-28 16:43:10">2025-07-28</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/ROS/">ROS</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="container post-content" id="article-container"><h1 id="move-base中自定义导航算法插件制作"><a href="#move-base中自定义导航算法插件制作" class="headerlink" title="move_base中自定义导航算法插件制作"></a>move_base中自定义导航算法插件制作</h1><h2 id="流程："><a href="#流程：" class="headerlink" title="流程："></a>流程：</h2><p><strong>1.创建工作空间<br>2.创建导航包文件<br>3.创建头文件和源文件<br>4.写CMakeLists.txt生成库文件<br>5.建立插件描述文件xml<br>6.配置package.xml<br>7.查询插件是否注册<br>8.在move_base中调用插件</strong></p>
<hr>
<ul>
<li><p><strong>继承基类</strong>：需继承 <code>nav_core::BaseGlobalPlanner</code> 并重写虚函数。</p>
<table>
<thead>
<tr>
<th>虚函数</th>
<th>作用</th>
</tr>
</thead>
<tbody><tr>
<td><code>initialize()</code></td>
<td>初始化插件（必须非阻塞）（全、局）</td>
</tr>
<tr>
<td><code>makePlan()</code></td>
<td>计算全局路径（全）</td>
</tr>
<tr>
<td><code>computeVelocityCommands()</code></td>
<td>计算并发布速度指令（局）</td>
</tr>
<tr>
<td><code>isGoalReached()</code></td>
<td>检查是否到达目标（局）</td>
</tr>
<tr>
<td><code>setPlan()</code></td>
<td>接收全局路径（局）</td>
</tr>
</tbody></table>
</li>
</ul>
<hr>
<ul>
<li><strong>全局头文件</strong>：</li>
</ul>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifndef</span> NAV_H</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> NAV_H</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;ros/ros.h&gt;</span><span class="comment">//ROS 基础功能的集成头文件 </span></span></span><br><span class="line"><span class="comment">//包含常用 ROS 数据类型（如 ros::NodeHandle, ros::Rate）</span></span><br><span class="line"><span class="comment">//在 initialize() 中通过 NodeHandle 读取参数</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;geometry_msgs/PoseStamped.h&gt;</span><span class="comment">//定义带时间戳的位姿消息类型 </span></span></span><br><span class="line"><span class="comment">//makePlan() 的 start 和 goal 参数是该类型</span></span><br><span class="line"><span class="comment">//输出的路径点序列 plan 也是 PoseStamped 的集合</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;costmap_2d/costmap_2d_ros.h&gt;</span><span class="comment">//提供代价地图的访问接口</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;costmap_2d/costmap_2d.h&gt;</span></span></span><br><span class="line"><span class="comment">//在 makePlan() 中通过 costmap_ros 查询障碍物信息，避免碰撞</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;nav_core/base_global_planner.h&gt;</span><span class="comment">//引入 ROS 全局路径规划器的基类接口</span></span></span><br><span class="line">  </span><br><span class="line">  <span class="keyword">namespace</span> global_planner &#123; <span class="comment">//避免命名冲突，将自定义规划器逻辑隔离在global_planner命名空间内</span></span><br><span class="line">    <span class="keyword">class</span> <span class="title class_">GlobalPlanner</span> : <span class="keyword">public</span> nav_core::BaseGlobalPlanner &#123; <span class="comment">//GlobalPlanner 继承自 ROS 导航栈的标准全局规划器接口</span></span><br><span class="line">    <span class="keyword">public</span>:<span class="comment">//对外接口</span></span><br><span class="line">      <span class="built_in">GlobalPlanner</span>();<span class="comment">//默认构造函数：供插件系统动态加载时调用。</span></span><br><span class="line">      <span class="built_in">GlobalPlanner</span>(std::string name, costmap_2d::Costmap2DROS* costmap_ros);<span class="comment">//带参构造函数：直接初始化时传递规划器名称和代价地图。</span></span><br><span class="line">      <span class="function"><span class="type">void</span> <span class="title">initialize</span><span class="params">(std::string name, costmap_2d::Costmap2DROS* costmap_ros)</span></span>;</span><br><span class="line">      <span class="comment">/*功能：初始化规划器。</span></span><br><span class="line"><span class="comment">    	参数：</span></span><br><span class="line"><span class="comment">        name：规划器名称（用于 ROS 参数服务器配置）。</span></span><br><span class="line"><span class="comment">        costmap_ros：指向全局代价地图的指针（包含障碍物信息）。</span></span><br><span class="line"><span class="comment">    	实现要求：</span></span><br><span class="line"><span class="comment">        必须保存 costmap_ros 供后续路径规划使用（通常赋值给私有成员 costmap_ros_）。</span></span><br><span class="line"><span class="comment">        非阻塞操作，避免长时间初始化。*/</span></span><br><span class="line">      <span class="function"><span class="type">bool</span> <span class="title">makePlan</span><span class="params">(<span class="type">const</span> geometry_msgs::PoseStamped&amp; start,</span></span></span><br><span class="line"><span class="params"><span class="function">                    <span class="type">const</span> geometry_msgs::PoseStamped&amp; goal,</span></span></span><br><span class="line"><span class="params"><span class="function">                    std::vector&lt;geometry_msgs::PoseStamped&gt;&amp; plan)</span></span>;</span><br><span class="line">        <span class="comment">/*功能：计算从 start 到 goal 的路径。</span></span><br><span class="line"><span class="comment">		参数：</span></span><br><span class="line"><span class="comment">		start/goal：起点/终点的位姿（包含位置和朝向）。</span></span><br><span class="line"><span class="comment">		plan：输出参数，存储规划的路径点序列。</span></span><br><span class="line"><span class="comment">		返回值：成功返回 true，失败返回 false。</span></span><br><span class="line"><span class="comment">		关键规则：</span></span><br><span class="line"><span class="comment">		路径点必须按顺序从 start 到 goal 填充到 plan 中。*/</span></span><br><span class="line">    &#125;;</span><br><span class="line">  &#125;</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<ul>
<li><strong>局部头文件</strong>：</li>
</ul>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;nav_core/base_local_planner.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;costmap_2d/costmap_2d_ros.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">namespace</span> local_planner &#123;</span><br><span class="line"><span class="keyword">class</span> <span class="title class_">LocalPlanner</span> : <span class="keyword">public</span> nav_core::BaseLocalPlanner &#123;</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">  <span class="built_in">LocalPlanner</span>();</span><br><span class="line">  <span class="function"><span class="type">void</span> <span class="title">initialize</span><span class="params">(std::string name, tf2_ros::Buffer* tf, costmap_2d::Costmap2DROS* costmap_ros)</span></span>; </span><br><span class="line">    	<span class="comment">/*</span></span><br><span class="line"><span class="comment">    	完成规划器的一次性初始化，包括：</span></span><br><span class="line"><span class="comment">        存储代价地图指针(costmap_ros)</span></span><br><span class="line"><span class="comment">        初始化TF坐标变换监听器(tf)</span></span><br><span class="line"><span class="comment">        从ROS参数服务器读取配置参数</span></span><br><span class="line"><span class="comment">        创建ROS发布器/订阅器（如速度指令发布器）</span></span><br><span class="line"><span class="comment">        */</span></span><br><span class="line">  <span class="function"><span class="type">bool</span> <span class="title">computeVelocityCommands</span><span class="params">(geometry_msgs::Twist&amp; cmd_vel)</span></span>;</span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        核心算法函数：根据当前环境和全局路径，计算机器人应执行的速度指令</span></span><br><span class="line"><span class="comment">        典型操作：</span></span><br><span class="line"><span class="comment">        检测障碍物（通过costmap_ros_）</span></span><br><span class="line"><span class="comment">        查询机器人当前位姿（通过tf_）</span></span><br><span class="line"><span class="comment">        实现控制算法（如DWA、PID等）</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">  <span class="function"><span class="type">bool</span> <span class="title">isGoalReached</span><span class="params">()</span></span>;</span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        判断机器人是否到达目标点</span></span><br><span class="line"><span class="comment">    	检查条件通常包括：</span></span><br><span class="line"><span class="comment">        位置容差（如距离目标&lt;0.1m）</span></span><br><span class="line"><span class="comment">        朝向容差（如角度偏差&lt;0.1rad）</span></span><br><span class="line"><span class="comment">        速度接近零（可选）</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">  <span class="function"><span class="type">bool</span> <span class="title">setPlan</span><span class="params">(<span class="type">const</span> std::vector&lt;geometry_msgs::PoseStamped&gt;&amp; plan)</span></span>;</span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">    	接收来自全局规划器生成的路径（nav_msgs/Path）</span></span><br><span class="line"><span class="comment">    	对路径进行预处理（如简化、平滑或转换坐标系）</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">&#125;;</span><br><span class="line">&#125; <span class="comment">// namespace my_ns</span></span><br></pre></td></tr></table></figure>



<hr>
<ul>
<li><strong>全局源文件</strong>：</li>
</ul>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;global_planner/global_planner.h&quot;</span><span class="comment">//导入自己编写的头文件 include内头文件路径（隐式依赖了一些需要头文件）</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pluginlib/class_list_macros.h&gt;</span><span class="comment">//注册插件宏头文件</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;nav_msgs/Path.h&gt;</span></span></span><br><span class="line"><span class="comment">//作用：定义 nav_msgs::Path 消息类型</span></span><br><span class="line"><span class="comment">//必须场景：需要发布或处理路径数据</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">PLUGINLIB_EXPORT_CLASS</span>(global_planner::GlobalPlanner, nav_core::BaseGlobalPlanner)<span class="comment">//注册插件宏</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">namespace</span> global_planner &#123;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 默认构造函数</span></span><br><span class="line">GlobalPlanner::<span class="built_in">GlobalPlanner</span>()&#123;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 带参构造函数（委托给initialize）</span></span><br><span class="line">GlobalPlanner::<span class="built_in">GlobalPlanner</span>(std::string name, costmap_2d::Costmap2DROS* costmap_ros)&#123;  </span><br><span class="line">  <span class="built_in">initialize</span>(name, costmap_ros);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 初始化函数实现</span></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">GlobalPlanner::initialize</span><span class="params">(std::string name, costmap_2d::Costmap2DROS* costmap_ros)</span> </span>&#123;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">GlobalPlanner::makePlan</span><span class="params">(</span></span></span><br><span class="line"><span class="params"><span class="function">    <span class="type">const</span> geometry_msgs::PoseStamped&amp; start,</span></span></span><br><span class="line"><span class="params"><span class="function">    <span class="type">const</span> geometry_msgs::PoseStamped&amp; goal,</span></span></span><br><span class="line"><span class="params"><span class="function">    std::vector&lt;geometry_msgs::PoseStamped&gt;&amp; plan)</span> </span>&#123;</span><br><span class="line">                <span class="built_in">ROS_INFO</span>(<span class="string">&quot;make plan start:[%f %f], goal:[%f %f]&quot;</span>, </span><br><span class="line">                           start.pose.position.x, </span><br><span class="line">                           start.pose.position.y, </span><br><span class="line">                           goal.pose.position.x, </span><br><span class="line">                           goal.pose.position.y);<span class="comment">//在ROS日志中记录路径规划的起点和目标点坐标，用于调试和监控</span></span><br><span class="line">                plan.<span class="built_in">clear</span>();<span class="comment">//清除输出参数 plan（std::vector&lt;geometry_msgs::PoseStamped&gt;）中的旧数据，确保路径是全新的</span></span><br><span class="line">                <span class="type">float</span> yaw = <span class="built_in">atan2</span>(goal.pose.position.y - start.pose.position.y, goal.pose.position.x - start.pose.position.x);<span class="comment">//atan2(dy, dx) 计算从起点指向目标点的方位角（弧度制）</span></span><br><span class="line">                <span class="type">int</span> n = <span class="number">0</span>;</span><br><span class="line">                <span class="type">float</span> goal_distance = <span class="built_in">sqrt</span>(<span class="built_in">pow</span>((start.pose.position.x - goal.pose.position.x), <span class="number">2</span>) + <span class="built_in">pow</span>((start.pose.position.y - goal.pose.position.y), <span class="number">2</span>));<span class="comment">//计算起点到目标点的直线距离</span></span><br><span class="line">                <span class="type">float</span> delta = <span class="number">0.1</span>; <span class="comment">// 间隔delta输出start至end的直线上的点 我们间隔0.1取直线上的所有点，放到输出的参数plan里</span></span><br><span class="line">                <span class="keyword">while</span> (n * delta &lt; goal_distance)</span><br><span class="line">                &#123;</span><br><span class="line">                    geometry_msgs::PoseStamped pose = goal;</span><br><span class="line"></span><br><span class="line">                    pose.pose.position.x = (n * delta) * <span class="built_in">cos</span>(yaw) + start.pose.position.x;</span><br><span class="line">                    pose.pose.position.y = (n * delta) * <span class="built_in">sin</span>(yaw) + start.pose.position.y;</span><br><span class="line">                    ++n;</span><br><span class="line">                    plan.<span class="built_in">push_back</span>(pose);</span><br><span class="line">                &#125;</span><br><span class="line"></span><br><span class="line">                plan.<span class="built_in">push_back</span>(goal); <span class="comment">// 确保终点被包含</span></span><br><span class="line"></span><br><span class="line">                <span class="keyword">return</span> !plan.<span class="built_in">empty</span>();<span class="comment">//true：路径生成成功（plan 非空）。</span></span><br><span class="line">                &#125;</span><br><span class="line">&#125; <span class="comment">// namespace global_planner</span></span><br></pre></td></tr></table></figure>
<p><strong>局部源文件</strong>：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;local_planner/local_planner.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pluginlib/class_list_macros.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="built_in">PLUGINLIB_EXPORT_CLASS</span>(local_planner::LocalPlanner, nav_core::BaseLocalPlanner)</span><br><span class="line"></span><br><span class="line"><span class="keyword">namespace</span> local_planner &#123;</span><br><span class="line"></span><br><span class="line">LocalPlanner::<span class="built_in">LocalPlanner</span>()&#123;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">LocalPlanner::initialize</span><span class="params">(std::string name, tf2_ros::Buffer* tf, costmap_2d::Costmap2DROS* costmap_ros)</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">LocalPlanner::computeVelocityCommands</span><span class="params">(geometry_msgs::Twist&amp; cmd_vel)</span> </span>&#123;</span><br><span class="line">  <span class="comment">// 实现控制逻辑（如DWA算法）</span></span><br><span class="line">  <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">LocalPlanner::setPlan</span><span class="params">(<span class="type">const</span> std::vector&lt;geometry_msgs::PoseStamped&gt;&amp; orig_global_plan)</span> </span>&#123;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">LocalPlanner::isGoalReached</span><span class="params">()</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">&#125; <span class="comment">// namespace local_planner</span></span><br></pre></td></tr></table></figure>

<hr>
<ul>
<li><strong>以下均以全局示例</strong>：</li>
<li><strong>CMakeLists.txt添加生成动态链接库</strong></li>
</ul>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">add_library(global_planner_lib</span><br><span class="line">src/global_planner.cpp</span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<p>然后在终端运⾏ catkin_make 在 catkin ⼯作区⽬录下⽣成⼆进制⽂件。<br>这将在 lib ⽬录 ~&#x2F;工作空间&#x2F;devel&#x2F;lib&#x2F; 中⽣成 <code>libglobal_planner_lib.so</code> 库⽂件。</p>
<hr>
<ul>
<li><strong>编写插件描述文件（XML）</strong></li>
<li><strong>文件示例</strong>：<code>global_planner_plugin.xml</code></li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">  <span class="tag">&lt;<span class="name">library</span> <span class="attr">path</span>=<span class="string">&quot;lib/libglobal_planner_lib&quot;</span>&gt;</span> </span><br><span class="line">      <span class="comment">&lt;!--指定插件动态库的路径</span></span><br><span class="line"><span class="comment">    对应实际库文件~/工作空间/devel/lib/libglobal_planner_lib.so</span></span><br><span class="line"><span class="comment">注意事项：</span></span><br><span class="line"><span class="comment">    路径相对于devel/lib/目录</span></span><br><span class="line"><span class="comment">    必须与add_library()中定义的库名一致--&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">class</span> <span class="attr">name</span>=<span class="string">&quot;global_planner/GlobalPlanner&quot;</span></span></span><br><span class="line"><span class="tag">           <span class="attr">type</span>=<span class="string">&quot;global_planner::GlobalPlanner&quot;</span></span></span><br><span class="line"><span class="tag">           <span class="attr">base_class_type</span>=<span class="string">&quot;nav_core::BaseGlobalPlanner&quot;</span>&gt;</span></span><br><span class="line">           <span class="comment">&lt;!--name:定义ROS系统中调用该插件的唯一标识符</span></span><br><span class="line"><span class="comment">               建议使用包名/类名的格式避免冲突</span></span><br><span class="line"><span class="comment">               需与PLUGINLIB_EXPORT_CLASS宏中的名称一致</span></span><br><span class="line"><span class="comment">               在launch文件中调用时使用：&lt;param name=&quot;base_global_planner&quot; value=&quot;global_planner/GlobalPlanner&quot;/&gt;</span></span><br><span class="line"><span class="comment">               type:指定插件类的完整限定名</span></span><br><span class="line"><span class="comment">               格式：命名空间::类名</span></span><br><span class="line"><span class="comment">               对应头文件中的类定义</span></span><br><span class="line"><span class="comment">               base_class_type:声明插件继承的基类接口</span></span><br><span class="line"><span class="comment">               格式：基类命名空间::基类名</span></span><br><span class="line"><span class="comment">               必须与PLUGINLIB_EXPORT_CLASS宏的第二个参数完全一致</span></span><br><span class="line"><span class="comment">               --&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">description</span>&gt;</span>This is a global planner plugin by bbb.<span class="tag">&lt;/<span class="name">description</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">class</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">library</span>&gt;</span></span><br></pre></td></tr></table></figure>

<hr>
<ul>
<li><strong>配置package.xml</strong></li>
<li><strong>添加依赖</strong>:</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">build_depend</span>&gt;</span>nav_core<span class="tag">&lt;/<span class="name">build_depend</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">build_export_depend</span>&gt;</span>nav_core<span class="tag">&lt;/<span class="name">build_export_depend</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">exec_depend</span>&gt;</span>nav_core<span class="tag">&lt;/<span class="name">exec_depend</span>&gt;</span></span><br></pre></td></tr></table></figure>
<ul>
<li><strong>导出插件</strong>：</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">export</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">nav_core</span> <span class="attr">plugin</span>=<span class="string">&quot;$&#123;prefix&#125;/global_planner_plugin.xml&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">export</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!--nav_core：表示插件类型（与基类所属包一致）</span></span><br><span class="line"><span class="comment">  $&#123;prefix&#125;：自动替换为当前包的安装路径（如/opt/ros/noetic/share/your_pkg）</span></span><br><span class="line"><span class="comment">  global_planner_plugin.xml：插件描述文件路径（需与之前创建的XML文件同名）--&gt;</span></span><br></pre></td></tr></table></figure>
<hr>
<ul>
<li><strong>查询插件是否注册</strong></li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rospack plugins --attrib=plugin nav_core</span><br></pre></td></tr></table></figure>

<hr>
<ul>
<li><strong>修改launch文件</strong>：</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">launch</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">node</span> <span class="attr">pkg</span>=<span class="string">&quot;move_base&quot;</span> <span class="attr">type</span>=<span class="string">&quot;move_base&quot;</span> <span class="attr">name</span>=<span class="string">&quot;move_base&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">param</span> <span class="attr">name</span>=<span class="string">&quot;base_global_planner&quot;</span> <span class="attr">value</span>=<span class="string">&quot;global_planner/GlobalPlanner&quot;</span>/&gt;</span></span><br><span class="line">    <span class="comment">&lt;!--name:base_global_planner：move_base的固定参数名，用于设置全局规划器</span></span><br><span class="line"><span class="comment">  	value=&quot;global_planner/GlobalPlanner&quot;：插件标识符，对应插件描述文件中的&lt;class name&gt;--&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">node</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">launch</span>&gt;</span></span><br></pre></td></tr></table></figure>

</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io">Fi9zero</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io/2025/05/20/2025-05-20-move_base%E4%B8%AD%E8%87%AA%E5%AE%9A%E4%B9%89%E5%AF%BC%E8%88%AA%E7%AE%97%E6%B3%95%E6%8F%92%E4%BB%B6%E5%88%B6%E4%BD%9C/">https://ckyfi9zero.github.io/2025/05/20/2025-05-20-move_base%E4%B8%AD%E8%87%AA%E5%AE%9A%E4%B9%89%E5%AF%BC%E8%88%AA%E7%AE%97%E6%B3%95%E6%8F%92%E4%BB%B6%E5%88%B6%E4%BD%9C/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来源 <a href="https://ckyfi9zero.github.io" target="_blank">荒岛</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/ROS/">ROS</a><a class="post-meta__tags" href="/tags/move-base/">move_base</a></div><div class="post-share"><div class="social-share" data-image="/image/avatar.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><a class="pagination-related  no-desc" href="/2025/07/27/2025-07-27-%E6%96%B0%E4%B8%96%E7%95%8C/" title="新世界"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info"><div class="info-1"><div class="info-item-1">上一篇</div><div class="info-item-2">新世界</div></div></div></a><a class="pagination-related  no-desc" href="/2025/05/06/2025-05-06-Ubuntu-GRUB-%E4%BF%AE%E5%A4%8D%E6%8C%87%E5%8D%97/" title="Ubuntu GRUB 修复指南"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-right"><div class="info-1"><div class="info-item-1">下一篇</div><div class="info-item-2">Ubuntu GRUB 修复指南</div></div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a class="pagination-related no-desc" href="/2025/07/30/2025-07-30-%E8%BF%90%E8%A1%8CinterD455%E7%9B%B8%E6%9C%BA/" title="运行interD455相机"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-30</div><div class="info-item-2">运行interD455相机</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-ROS%E4%B8%8B%E8%BF%9B%E8%A1%8C%E7%82%B9%E4%BA%91%E6%95%B0%E6%8D%AE%E5%AE%9E%E6%97%B6%E8%8E%B7%E5%8F%96/" title="ROS下进行点云数据实时获取"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">ROS下进行点云数据实时获取</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E4%BD%BF%E7%94%A8D455%E8%B7%91%E9%80%9Artabmap/" title="使用D455跑通rtabmap"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">使用D455跑通rtabmap</div></div></div></a></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info text-center"><div class="avatar-img"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info-name">Fi9zero</div><div class="author-info-description"></div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/ckyFi9zero"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons"><a class="social-icon" href="https://github.com/ckyFi9zero" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:2539894206@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#move-base%E4%B8%AD%E8%87%AA%E5%AE%9A%E4%B9%89%E5%AF%BC%E8%88%AA%E7%AE%97%E6%B3%95%E6%8F%92%E4%BB%B6%E5%88%B6%E4%BD%9C"><span class="toc-number">1.</span> <span class="toc-text">move_base中自定义导航算法插件制作</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B5%81%E7%A8%8B%EF%BC%9A"><span class="toc-number">1.1.</span> <span class="toc-text">流程：</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/10/05/2025-10-05-lio_sam/" title="lio_sam">lio_sam</a><time datetime="2025-10-05T02:43:51.000Z" title="发表于 2025-10-05 10:43:51">2025-10-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/12/2025-08-12-%E4%BD%BF%E7%94%A8docker%E6%90%AD%E5%BB%BApytorch%E7%8E%AF%E5%A2%83/" title="使用docker搭建pytorch环境">使用docker搭建pytorch环境</a><time datetime="2025-08-12T12:43:33.000Z" title="发表于 2025-08-12 20:43:33">2025-08-12</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-docker/" title="docker">docker</a><time datetime="2025-08-05T11:02:36.000Z" title="发表于 2025-08-05 19:02:36">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E8%BF%90%E5%8A%A8%E5%AF%B9%E8%B1%A1%E5%88%86%E5%89%B2%E4%B8%8E%E9%85%8D%E5%87%86%E7%AE%97%E6%B3%95/" title="运动对象分割与配准算法">运动对象分割与配准算法</a><time datetime="2025-08-05T08:16:02.000Z" title="发表于 2025-08-05 16:16:02">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E6%9D%A1%E4%BB%B6%E6%AC%A7%E5%BC%8F%E8%81%9A%E7%B1%BB%E5%88%86%E5%89%B2/" title="条件欧式聚类分割">条件欧式聚类分割</a><time datetime="2025-08-05T07:56:39.000Z" title="发表于 2025-08-05 15:56:39">2025-08-05</time></div></div></div></div></div></div></main><footer id="footer"><div class="footer-other"><div class="footer-copyright"><span class="copyright">&copy;&nbsp;2025 By Fi9zero</span><span class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo 7.3.0</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly 5.4.2</a></span></div><div class="footer_custom_text">Only light can attract bugs.</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><div class="js-pjax"><script>(() => {
  const loadMathjax = () => {
    if (!window.MathJax) {
      window.MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']],
          tags: 'none',
        },
        chtml: {
          scale: 1.1
        },
        options: {
          enableMenu: true,
          renderActions: {
            findScript: [10, doc => {
              for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
                const display = !!node.type.match(/; *mode=display/)
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
                const text = document.createTextNode('')
                node.parentNode.replaceChild(text, node)
                math.start = {node: text, delim: '', n: 0}
                math.end = {node: text, delim: '', n: 0}
                doc.math.push(math)
              }
            }, '']
          }
        }
      }

      const script = document.createElement('script')
      script.src = 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js'
      script.id = 'MathJax-script'
      script.async = true
      document.head.appendChild(script)
    } else {
      MathJax.startup.document.state(0)
      MathJax.texReset()
      MathJax.typesetPromise()
    }
  }

  btf.addGlobalFn('encrypt', loadMathjax, 'mathjax')
  window.pjax ? loadMathjax() : window.addEventListener('load', loadMathjax)
})()</script><script>(() => {
  const runMermaid = ele => {
    window.loadMermaid = true
    const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

    ele.forEach((item, index) => {
      const mermaidSrc = item.firstElementChild
      const mermaidThemeConfig = `%%{init:{ 'theme':'${theme}'}}%%\n`
      const mermaidID = `mermaid-${index}`
      const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent

      const renderFn = mermaid.render(mermaidID, mermaidDefinition)
      const renderMermaid = svg => {
        mermaidSrc.insertAdjacentHTML('afterend', svg)
      }

      // mermaid v9 and v10 compatibility
      typeof renderFn === 'string' ? renderMermaid(renderFn) : renderFn.then(({ svg }) => renderMermaid(svg))
    })
  }

  const codeToMermaid = () => {
    const codeMermaidEle = document.querySelectorAll('pre > code.mermaid')
    if (codeMermaidEle.length === 0) return

    codeMermaidEle.forEach(ele => {
      const preEle = document.createElement('pre')
      preEle.className = 'mermaid-src'
      preEle.hidden = true
      preEle.textContent = ele.textContent
      const newEle = document.createElement('div')
      newEle.className = 'mermaid-wrap'
      newEle.appendChild(preEle)
      ele.parentNode.replaceWith(newEle)
    })
  }

  const loadMermaid = () => {
    if (true) codeToMermaid()
    const $mermaid = document.querySelectorAll('#article-container .mermaid-wrap')
    if ($mermaid.length === 0) return

    const runMermaidFn = () => runMermaid($mermaid)
    btf.addGlobalFn('themeChange', runMermaidFn, 'mermaid')
    window.loadMermaid ? runMermaidFn() : btf.getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaidFn)
  }

  btf.addGlobalFn('encrypt', loadMermaid, 'mermaid')
  window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
})()</script></div><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer data-pjax src="/js/pig.js"></script><script src="/js/weather.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="text-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="站内搜索..." type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>